/*===========================================================
 
 .---=||||[ B L O O D Y ]|||||=====================----------....
 |                                                              |
 |    THE  M O S T   B L O O D Y  GAME EVER!                    |
 |                                                              |
 |    bloody harvest is coming... soon,                         |
 |                                              heil Satan!     |
 !                                                              !
 .                                                              ,
  ~~~~-------------================================|||||||||==-~




 Name-Space: {core, logic, editor}
 Module: {draw, coll, scgr, ...}
 Class: <name of class>
 Last modification:  <author>, <time>

 TODO:
 <-------- todo #1 ---------->
 <-------- todo #2 ---------->
 <-------- todo #3 ---------->
        ............
 <-------- todo #n ---------->

 FIX:
 <-------- fix #1 ----------->
 <-------- fix #1 ----------->
         ..........
 <-------- fix #n ----------->




 
 
 ============================================================*/
#include "core/evnt/Mouse.h"

namespace core
{
	namespace evnt
	{
		
	
	  Mouse::Mouse()
	  {
	    x = y = button = 0;
	  }
		
	  Mouse::~Mouse()
	  {
	  }
		
	  void Mouse::processButtonEvent(const SDL_MouseButtonEvent& event)
	  {
	    int bt = 0;
	    switch (event.button) {
	    case SDL_BUTTON_LEFT:
	      bt = LeftButton;
	      break;
	      
	    case SDL_BUTTON_MIDDLE:
	      bt = MiddleButton;
	      break;
			  
	    case SDL_BUTTON_RIGHT:
	      bt = RightButton;
	      break;
	    }
	    
	    switch (event.type) {
	    case SDL_MOUSEBUTTONUP:
	      button &= 0xff ^ bt;
	      break;
	      
	    case SDL_MOUSEBUTTONDOWN:
	      button |= bt;
	      break;
	    }
	  }
		
	  void Mouse::processMotionEvent(const SDL_MouseMotionEvent& event)
	  {
	    x = event.x;
	    y = event.y;
	  }
	  
	  void Mouse::show(){ SDL_ShowCursor(SDL_ENABLE); }
	  void Mouse::hide(){ SDL_ShowCursor(SDL_DISABLE); }
	  
	  void Mouse::setXY(int x, int y)
	  {
	    this->x = x;
	    this->y = y;
	    SDL_WarpMouse(x,y);
	  }
	}
}

